<?php

namespace app\common\validate;

use think\Validate;

class Trade extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        // 'action'    => 'require|in:sell,buy',
        'symbol'    => 'require',
        'tosymbol'  => 'require',
        // 'exch_rate' => 'require',
        'num'       => 'require|number|checknum',
        // 'status'    => 'require|in:0,1,2,3,4,5'

    ];
    /**
     * 提示消息
     */
    protected $message = [
        // 'action.require'    => '请输入操作请求',
        // 'action.in'         => 'sell,buy',
        'symbol.require'    => '输入卖出货币',
        'tosymbol.require'  => '输入兑换货币',
        // 'exch_rate.require' => '请计算汇率',
        'num.require'       => '输入买卖数量',
        'num.number'       => '请填写正确数字',
        'num.checknum'       => '请输入交易数量',
        // 'status.require'    => '状态不正确, 0,1,2,3,4,5'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['action','symbol','tosymbol','exch_rate','num','status'],
        'edit' => [],
    ];

    /**
     * 验证数量
     * @param  [type] $value [description]
     * @param  [type] $rule  [description]
     * @return [type]        [description]
     */
    public function checknum($value,$rule)
    {
        if ($value<=0) {
            return false;
        }
        return true;
    }

    
}
